const bcrypt = require('bcryptjs');

/**
 * @param { import("knex").Knex } knex
 * @returns { Promise<void> } 
 */
exports.seed = async function(knex) {
  // Deletes ALL existing entries
  await knex('users').del();

  const passwordHash = await bcrypt.hash('password123', 12);
  
  // Inserts seed entries
  await knex('users').insert([
    {
      username: 'admin',
      email: 'admin@example.com',
      password_hash: passwordHash,
      first_name: 'Admin',
      last_name: 'User',
      role: 'admin',
      status: 'active',
      email_verified_at: new Date(),
    },
    {
      username: 'john_doe',
      email: 'john@example.com',
      password_hash: passwordHash,
      first_name: 'John',
      last_name: 'Doe',
      role: 'user',
      status: 'active',
      email_verified_at: new Date(),
    },
    {
      username: 'jane_smith',
      email: 'jane@example.com',
      password_hash: passwordHash,
      first_name: 'Jane',
      last_name: 'Smith',
      role: 'user',
      status: 'active',
      email_verified_at: new Date(),
    }
  ]);
};